/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fileprocessor_sdt1;

import Proxy.FileInterface;
import Proxy.MyFile;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;

/**
 *
 * @author Andreea
 */
public class Test {
    public static void main(String[] args) {
        File folder = new File("D:\\");
        ArrayList<FileInterface> myFiles=new ArrayList<FileInterface>();
        List<File> list = new ArrayList<File>();
        getFiles(folder, list,myFiles);
        System.out.println(myFiles.size());
    }
 
    private static void getFiles(File folder, List<File> list,ArrayList<FileInterface> myFiles) {
        folder.setReadOnly();
        File[] files = folder.listFiles();
        for(int j = 0; j < files.length; j++) {      
            //System.out.println(files[j].getName());
            if(files[j].isDirectory()&&!files[j].isHidden())
                getFiles(files[j], list,myFiles);
            else{
                String name=files[j].getName();
                int index=name.lastIndexOf(".");
                String extension=name.substring(index+1,name.length());
                if (extension.equalsIgnoreCase("xml")){
                    MyFile f=new MyFile(files[j].getName(),files[j].length(),files[j].getAbsolutePath(),files[j].length());
                    myFiles.add(f);
                    System.out.println(f.getContent());
                    list.add(files[j]);
                }
            }
        }
    }
}
